﻿@{
    ViewBag.Title = "Common Command";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
       <ol class="breadcrumb">
    <li><a href="/Home/Home">Home</a></li>
    <li><a href="/Core/Introduction"> Sanelib Core</a></li>
    <li class="active">Event Handlers</li>
</ol>

            <div id="introduction">
                <h1 class="text-left">Event Handlers</h1>
                <p>Event handlers purpose of for handles the event.Event handler works same as command processor but in command processor required user and after done return some value, and Event handler not required any kind of user and no return any value. Event handlers implements by IEvent Handler interface. IEventHandler contain handle abstract method.</p>
                <pre><code>public interface IEventHandler&lt;in tevent&gt; where TEvent : IEvent<br />{<br />void Handle(TEvent evt);<br />}</code></pre>
                <p>IEvent Handler is generic interface and contain handle method that handle event. Handle Method is for handles the event. Event handler pass one argument as event. </p>
                <pre><code>public class MemberRegistrationHandler : IEventHandler&lt;memberregistration&gt;<br />{<br />   public void Handle(MemberRegistration evt)<br />  {<br />  }<br />}</code></pre>
                <p>Event handler contain handler method that pass event and handle. In the handler intilise the models variables and add into repository. </p>
                <pre><code>private readonly IRepository&lt;member&gt; _repository;</code></pre>
                <p>IRepository is generic interface that contain methods</p>
                <pre><code>public interface IRepository&lt;t&gt; where T : Entity
    {
        T GetById(Guid id);
        T GetByKey(string keyName, object keyVal);
        T Add(T entity);
        T Update(T entity);
        void Delete(Guid id);
        IList&lt;t&gt; GetAllFor(string keyName, object keyVal);
        void ExecuteCommand(string commandSet, Action&lt;sqlcommand&gt; addCommandParams);
        object ExecuteScaler(string storeProcName, Action&lt;sqlcommand&gt; addCommandParams);
    }</code></pre>
                <ul>
                    <li><p>GetById- Using this method get id for paricular member.</p></li>
                    <li><p>GetByKey- To get paricular property from member.</p></li>
                    <li><p>Add, Update, Delete method for opertion on paricular entity.</p></li>
                    <li><p>GetAllFor using for get all property from member.</p></li>
                </ul>
                

            </div>
